home *** CD-ROM | disk | FTP | other *** search
- From: jason@cygnus.com (Jason Merrill)
- Message-ID: <u93f63214o.fsf@yorick.cygnus.com>
- X-Original-Date: 16 Apr 1996 16:35:35 -0700
- Path: in2.uu.net!bounce-back
- Date: 17 Apr 96 08:49:00 GMT
- Approved: fjh@cs.mu.oz.au
- Newsgroups: comp.std.c++
- Subject: Re: Just one more library function
- Organization: Cygnus Support, Mountain View, CA
- References: <Pine.HPP.3.91.960416133333.19297A-100000@hadron.fi.uib.no>
- In-Reply-To: Igor Boukanov's message of 16 Apr 1996 13:15:25 PDT
- X-Newsreader: Gnus v5.0
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBFAgUBMXSwluEDnX0m9pzZAQFSKAF/eQj/ntLuT9R9kmR4uCjP/mXtfa436RiL
- YXZXPBecWeVlQxAINDOw9LWD9RAmezkq
- =qZG4
-
- >>>>> Igor Boukanov <Igor.Boukanov@fi.uib.no> writes:
-
- > Why do not require that every C++ implementation should provide function
- > that will return for the pointer obtained from new[] the number of
- > allocated elements, i.e. something like:
-
- > template<class T> size_t array_allocation_size(T* p);
-
- > So for 'int* p = new int[3];' 'array_allocation_size(p)' will return 3.
-
- > Such function will be very easy to implement because in the case of
- > delete[] compiler use something like this.
-
- Not necessarily. For instance, g++ only stores the number of elements if
-
- 1) The element type has a destructor, or
- 2) The element type has an operator delete that takes the size_t argument.
-
- Jason
- ---
- [ comp.std.c++ is moderated. To submit articles: try just posting with ]
- [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
- [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
- [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
- [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
-